package welcome;


import javax.swing.JFrame;

import welcome.general.ChoosePerspective;

/**
 * Creates a thread that wait for time specified to call the application.
 * @author F. OMENA
 *
 */
public class Timer extends Thread {  
	
	private JFrame logo;
	private int delayOfLogo = 2;

	@Override  
	public void run() {  
		try {  
			int cont =0;
			boolean openApp = false;
			
			while( !openApp ) {  
				if(cont++ == delayOfLogo){
					/* In correct delay, starts the application. */
					ChoosePerspective.load();
					openApp = true;
					logo.dispose();
				}
				Thread.sleep(1000);  
			}  
		} catch (Exception ex) {  
			ex.printStackTrace();  
		}  
	}

	public void setLogo(JFrame logo) {
		this.logo = logo;
	}  
	
	public void setDelay(int delay){
		this.delayOfLogo = delay;
	}
	
}  